package ui.components;

import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.data.general.Dataset;
import org.jfree.data.general.PieDataset;

import entities.QueryResult;

public abstract class Chart {
	private String chartTitle;
	protected ChartPanel chartPanel;
	public abstract ChartPanel getChart();
	public Chart(String chartTitle){
		this.chartTitle = chartTitle;
	}
	public void updateChart(QueryResult qResult){
				Dataset dataset = createDataset(qResult);
				JFreeChart chart = createChart(dataset, "");
				chartPanel = new ChartPanel(chart);
				chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
				chartPanel.setName(chartTitle);
	}
	protected abstract JFreeChart createChart(Dataset dataset, String chartTitle);
	protected abstract Dataset createDataset(QueryResult qResult);
}
